﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExaminationSys.DataAccess;
using ExaminationSys.DataAccess.Entity;
using ExaminationSys.DataAccess.Repository;
using Ext.Net;
using ExaminationSys.Helper;


namespace ExaminationSys.View.Paper
{
    public partial class PaperFeedBackCommentSelect : System.Web.UI.Page
    {
        private static readonly PaperFeedBackCommentService Proxy = ObjectFactory<PaperFeedBackCommentService>.Create();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
                PageEntity = null;
        }
        protected void Page_Init(object sender, EventArgs e)
        {

        }

        private int pageSize = 20;
        public static PageEntity PageEntity = null;
        protected void PaperFeedBackComment_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            string sqlWhere = " 1=1";
            int pageIndex = 0;
            if (PageEntity != null)
            {
                sqlWhere = PageEntity.SqlWhere;
                pageIndex = 1;
            }
            else
            {
                sqlWhere += string.Format(" and status<>0");
                pageIndex = (e.Start / e.Limit) + 1;

            }

            int totalPage, totalRecord;
            this.StorePaperFeedBackComment.DataSource = Proxy.GetListByPage(sqlWhere, " OperatorTime desc", pageSize, pageIndex,
                                                                   out totalPage, out totalRecord);
            e.Total = totalRecord;

            this.StorePaperFeedBackComment.DataBind();
        }

        protected void BtnGroupFind_Click(object sender, DirectEventArgs e)
        {
            var text = GroupSearchText.Text.Trim();
            if (!string.IsNullOrWhiteSpace(text))
            {
                text = text.SqlSafe();
                var sqlWhere = string.Format(" SectionID='{0}' and Type={1}  status<>0", "", ""); ;

                PageEntity = new PageEntity();
                PageEntity.SqlWhere = sqlWhere;
            }
            else
            {
                PageEntity = null;
            }
            StorePaperFeedBackComment.Reload();
        }


        protected void BtnSearch_Click(object sender, DirectEventArgs e)
        {
            //  this.PaperFeedBackCommentSearchWindow.Show(SearchFun);
        }
    }
}